#include "CTween.h"

Int32 CALLBACKTYPE GetQuinticValue(
    /* [in] */ Int32 fromValue,
    /* [in] */ Int32 toValue,
    /* [in] */ Millisecond32 elaspedTime,
    /* [in] */ Millisecond32 durationTime,
    /* [in] */ EaseType easeType)
{
    double dx = (float)(toValue - fromValue);
    double delta = 0;
    double ratio = ((double)elaspedTime) / durationTime;

    switch (easeType) {
        case EaseType_In:
            delta = dx * ratio * ratio * ratio * ratio * ratio;
        break;

        case EaseType_Out:
            ratio -= 1;
            delta = dx * (ratio * ratio * ratio * ratio * ratio + 1);
            break;

        case EaseType_InOut: {
            ratio *= 2.0;

            if (ratio < 1.0) {
                delta = dx * ratio * ratio * ratio * ratio * ratio * 0.5;
            }
            else {
                ratio -= 2;
                delta = dx * 0.5 * (ratio * ratio * ratio * ratio * ratio + 2);
        }
        break;
        }
        default:
            assert(0);
    }

    return fromValue + (Int32)(delta);
}
